Friend Class MonoSubCipherEngine

    Friend Function Encrypt(ByVal PlainText As String, ByVal Key As String) As String
        Dim CharArray(PlainText.Length - 1) As Char
        Dim KeyTable As New System.Collections.Specialized.ListDictionary

        'Build charecter replace table
        'A-Z in ASCII is 65-90
        'a-z in ASCII is 97-122
        For Count As Byte = 0 To 25
            KeyTable.Add((Count + 65).ToString, Key(Count).ToString.ToUpper)
            KeyTable.Add((Count + 97).ToString, Key(Count).ToString.ToLower)
        Next

        For Count As Byte = 0 To PlainText.Length - 1
            'transfer plain text to ASCII
            'and replace ASCII by compare charecter in table
            CharArray(Count) = KeyTable.Item(Asc(PlainText(Count)).ToString)
        Next

        Return CharArray
    End Function

    Friend Function Decrypt(ByVal CipherText As String, ByVal Key As String) As String
        Dim CharArray(CipherText.Length - 1) As Char
        Dim KeyTable As New System.Collections.Specialized.ListDictionary

        'Build charecter replace table
        'A-Z in ASCII is 65-90
        'a-z in ASCII is 97-122
        For Count As Byte = 0 To 25
            KeyTable.Add(Key(Count).ToString.ToUpper, (Count + 65).ToString)
            KeyTable.Add((Count).ToString.ToLower, (Count + 97).ToString)
        Next

        For Count As Byte = 0 To CipherText.Length - 1
            'find ASCII from table and transfer to charecter
            CharArray(Count) = Chr(KeyTable.Item(CipherText(Count).ToString))
        Next

        Return CharArray
    End Function

End Class
